import axios from "axios";

const instance = axios.create({
    // baseURL: "http://localhost:9090",
    timeout: 5000
});

instance.interceptors.request.use(config => {
    const token = localStorage.getItem("token");
    if (token && !config.url.endsWith("login")) {
        config.headers["Authorization"] = "";
    }
    return config
}, err => {
    return Promise.reject(err);
});

instance.interceptors.response.use(res => {
    console.log(res);
    if (res.status == 200) {
        return res.data
    }
    return false
}, err => {
    return Promise.reject(err)
})

export default instance